package com.altorithm;

/**
 * @Classname QuickSort
 * @Date 2019/9/27 10:05
 * @auther by hqy
 */
public class QuickSort {




    public static void sort(int[] array, int low, int high) {

        if (low < high) {
            int index = getIndex(array, low, high);

            sort(array, low, index - 1);
            sort(array, index + 1, high);

        }

    }

    static int getIndex(int[] array, int low, int high) {
        int temp = array[low];
        while (low < high) {

            while (low < high && array[high] >= temp) {
                high--;
            }
            array[low] = array[high];
            while (low < high && array[low] <= temp) {
                low++;
            }
            array[high] = array[low];

        }
        array[low] = temp;
        return low;
    }
}
